<!DOCTYPE html>
<html>
<head>
    <title>添加配置</title>
    <include file='public/head'>
	<style>
		.layui-legend-size{font-size:14px !important;}
		.layui-nopadding{padding:0 !important;}
		.layui-overflow{overflow:auto;}
		.layui-nomargin{margin: 0 !important;}
		.layui-bottom{border-bottom:1px solid rgb(226, 226, 226);}
		.layui-input{height:30px !important; }
		.layui-form-search-item .layui-inline{margin-bottom: 5px;} 
		.layui-form-search-item label{margin-left: 15px;}
		.layui-table-page {padding: 7px 0px 0px;}
		.layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}
		.new-ctrl{ width:100%; height:25px; border-radius:5px; };
	</style>
</head>
<body>
	<!-- layui-tab开始 -->
	<div class="layui-tab " lay-filter="demo-tab" >

	
		<!-- 内容开始 -->
			<!-- 表头按钮开始 -->

			<!-- 表头按钮结束 -->
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">图片</label></label>
                    <div class="layui-input-block">
                        <img id="img_logo" src="<?php if( $config['image'] ){  echo( zy_domain().$config['image'] ); } ?>"  alt="logo" style="width:150px;height:150px;border:1px solid #ccc;" /> 点击图片上传
                        <input type="hidden" id="logo_icon" name="image"   lay-verify="" placeholder="" autocomplete="off" class="layui-input" value="{$config.image|default=''}" />
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label class="layui-form-label">标题</label></label>
                    <div class="layui-input-block">
                        <input type="hidden" name="id" value="{$config.id|default='0'}" >
                        <input type="text" name="title" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input" value="{$config.title|default=''}" >
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label class="layui-form-label">简介</label></label>
                    <div class="layui-input-block">
                        <input type="text" name="introductory" required  lay-verify="required" placeholder="请输入简介" autocomplete="off" class="layui-input" value="{$config.introductory|default=''}" >
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label class="layui-form-label">超链接|路由</label></label>
                    <div class="layui-input-block">
                        <input type="radio" name="addr_type" value="0" title="超链接" <?php if( $config['addr_type'] == 0 ) echo  'checked';?> >
                        <input type="radio" name="addr_type" value="1" title="路由地址" <?php if( $config['addr_type'] == 1 ) echo  'checked';?> >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">地址</label></label>
                    <div class="layui-input-block">
                        <input type="text" name="addr" required  lay-verify="required" placeholder="请输入地址" autocomplete="off" class="layui-input" value="{$config.addr|default=''}" >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="status" value="1" title="显示" <?php if( $config['status'] == 1 ) echo  'checked';?> >
                        <input type="radio" name="status" value="0" title="隐藏" <?php if( $config['status'] == 0 ) echo  'checked';?> >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">时间(s)</label></label>
                    <div class="layui-input-block">
                        <input type="number" name="delay"  lay-verify="required" placeholder="请输入时间(s)" autocomplete="off" class="layui-input" value="{$config.delay|default='0'}" >
                    </div>
                </div>
                
                
                <div class="layui-form-item" style="display:none;">
                    <div class="layui-input-block">
                        <button class="layui-btn" id="form_tj" lay-submit lay-filter="formDemo">立即提交</button>
                    </div>
                </div>
                
            </form>
 
		<!-- 内容结束 -->
	</div>
	<!-- layui-tab结束-->
	<include file='public/scripts'>

	<script >
	;!function(){
	}();
	var form = layui.form
		,layer = layui.layer    //弹出层必需
		,layedit = layui.layedit  //富文本必需
		,laydate = layui.laydate  //日期选择必需
		,table = layui.table  //表格必需
		,element = layui.element;  //选项卡	
	var upload = layui.upload;

	//执行实例
    var uploadInst = upload.render({
        elem: '#img_logo' //绑定元素
        ,url: '{:cmf_plugin_url("SiteConfig://home_page_config/imageup")}' //上传接口
        ,done: function(res){
        //上传完毕回调
            layer.msg( res.message , { time:1000 , icon:(res.code ==200 )?1:5 } , function(){
                if ( res.code == 200 ){
                    $( '#img_logo' ).attr( 'src' , "<?php echo( zy_domain() ); ?>"+res.data );
                    $( '#logo_icon' ).val( res.data );
                }
            } );
        }
        ,error: function(){
        //请求异常回调
        }
    });
    
    form.on( "submit(formDemo)" , function( data ){
        $.post( '{:cmf_plugin_url("SiteConfig://home_page_config/postEditConfig")}' , {data:data.field} , function( res ){
	        layer.msg( res.message , { icon: res.code ? 1:5 , time : 800 } , function(){
	            if( res.code == 200 )
	            parent.location.reload();
	        } );
	    } );
        return false;
    });
    

	
	var callbackdata = function( index ){
        $( '#form_tj' ).click();
	}
	
	
	

	</script>


</body>
</html>